class LZWCoder 
{ 
private: 
        struct TStr 
        { 
                char *string; 
                unsigned int len; 
        }; 
        TStr StrTable[4097]; 
        unsigned int ItemPt; 
        unsigned int BytePt; 
        unsigned char BitPt; 
        unsigned char Bit[8]; 
        unsigned char Bits; 
        unsigned int OutBytes; 
        void InitStrTable(); 
        void CopyStr(TStr *d, TStr s); 
        void StrJoinChar(TStr *s, char c); 
        unsigned int InStrTable(TStr s); 
        void AddTableEntry(TStr s); 
        void WriteCode(char *dest, unsigned int b); 
        unsigned int GetNextCode(char *src); 
        void StrFromCode(TStr *s, unsigned int c); 
        void WriteString(char *dest, TStr s); 
public: 
		static LZWCoder& Instance(void);
        unsigned int Encode(char *src, unsigned int len, char *dest); 
        unsigned int Decode(char *src, unsigned int *len, char *dest); 
        LZWCoder(); 
        ~LZWCoder(); 
};

